import { _decorator, Component, Node } from 'cc';
import { PropItem } from '../PropItem';
import { BaseGame } from '../../../games/BaseGame';
import { _game, _tip } from '../../../Main';
import { MergeDish } from '../../../games/MergeDish';
import { GameState } from '../../../managers/GameManager';
const { ccclass, property } = _decorator;

@ccclass('MDClear')
export class MDClear extends PropItem {
    
    showName: string = '清理'

    shortDesc: string = '清理吧台上未合成的食物'

    fullDesc: string = '将清空吧台上未合成的全部食物'

    cost: number = 200

    useable(): boolean {
        let game: BaseGame = _game.game
        if (!(game instanceof MergeDish)) {
            return false
        }
        if (!game.isInGameState(GameState.Gaming)) {
            return false
        }
        if (game.isTrial()) {

            return false
        }
        if (!game.touchable) {
            _tip.tip('当前不可进行此操作')
            return false
        }
        if (game.getServedDishSize(false) <= 0) {
            _tip.tip('当前没有可以清理的食物')
            return false
        }
        return true
    }

    use(): void {
        let game: BaseGame = _game.game
        if (!(game instanceof MergeDish)) {
            return
        }
        game.clear()
    }
}


